package com.whmskj.xjlhbc.domain;

import cn.hutool.core.date.BetweenFormatter;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Data
@Schema(name = "维保记录请求响应参数",description = "维保记录请求响应参数")
@TableName(value = "by01MaintenanceSchedule",autoResultMap = true)
public class By01MaintenanceSchedule {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @Schema(description = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date otherOrganiser;

    @Schema(description = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date endTime;

    private String linksToTheProtectionPlan;

    private String deviceName;

    private Long numberOfEquipment;

    private String protector;

    @Schema(description = "状态")
    private String otherOrganiser1;

    private String maintenanceResults;

    private Date vipersTimeToStart;

    private Date itsTheEndOfViva;

    @Schema(description = "维保耗时")
    private String itsTimeconsuming;

    @Schema(description = "操作人")
    private String operator;

    private Date operationTime;

    private Integer linkPlanData;

    @Schema(description = "维保项目")
    private String projectForTheProtectionOfTheEnvi;

    @Schema(description = "设备名称")
    private String equipment;

    private String planned;

    private String scheduleNumber;

    private Integer f0a6;

    private Long guards;

    private String wb1;

    private String operator1;

    @Schema(description = "操作时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime fb0f;

    private Date submit;

    private String f5c8;

    private Date timeOfSubmission;

    @Schema(description = "维修人员")
    private String f896;

    @TableField(exist = false)
    @Schema(description = "职务")
    private String  typeOfEmployment;

    @Schema(description = "维修日期")
    private String vsDate;

    private String deviceNamenumber;

    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "维保图片")
    private List<Object> vivaPictures = new ArrayList<>();

    @Schema(description = "更换备件记录")
    private String replacementOfSparePartsRecords;

    @Schema(description = "备注")
    private String remarks;

    private String stationNumber1;

    private String stationNumber;
    @Schema(description = "车间")
    private String workshop;

    @TableField(exist = false)
    @Schema(description = "更换配件")
    private List<ReplaceAccessories> replaceAccessoriesList = new ArrayList<>();

    public String getItsTimeconsuming(){
        if(Objects.nonNull(otherOrganiser) && Objects.nonNull(endTime)){
            return DateUtil.formatBetween(otherOrganiser, endTime, BetweenFormatter.Level.SECOND);
        }
        return null;
    }

}
